with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO;
with Ada.Streams; use Ada.Streams;
with Interfaces; use Interfaces;
--with Ada.Direct_IO;
--with Ada.Sequential_IO;
With Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
package IO is

   --type Bit_Type is range 0..1;
   --for  Bit_Type use (0 => 0, 1 => 1);

   --type Flag_Array is array (Natural range <>) of Flag;
   --pragma Pack(Flag_Array);

   subtype Unsigned_22 is Unsigned_32 range 0..(2**22)-1;
   subtype Unsigned_6 is Unsigned_8 range 0..(2**6)-1;
   subtype Unsigned_5 is Unsigned_8 range 0..(2**5)-1;
   subtype Unsigned_3 is Unsigned_8 range 0..(2**3)-1;


   type Byte_Type is new Unsigned_8;
   for Byte_Type'Size use 8;
   for  Byte_Type'Alignment use 1;

   type Byte_Array is array (Natural range <>) of Byte_Type;
   pragma Pack(Byte_Array);

   subtype Bit_Type is Byte_Type range 0..1;
   --for Bit_Type'Size use 1;

   type Bit_Array is array (Natural range <>) of Bit_Type;
   pragma Pack(Bit_Array);

   type Word_16 is new Unsigned_16;
   for Word_16'Size use 2*8;
   for  Word_16'Alignment use 2;
   procedure Write_Network_Byte_Order(Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : in Word_16);
   for Word_16'Write use Write_Network_Byte_Order;



   type Byte_Buffer_Type(Buffer_Size : Natural) is
      record
         Byte_Buffer : Byte_Array(1 .. Buffer_Size);
         Start_Pos : Positive := 1;
         Size : Natural := 0;
         Is_Access_Unit : Boolean := True;
      end record;

   --package Dir_IO is new Ada.Direct_IO(Byte_Type);
   --package Dir_IO is new Ada.Sequential_IO(Byte_Type);

   package Stream_IO renames Ada.Streams.Stream_IO;

   type File_Type is
      record
         File : Stream_IO.FILE_TYPE;
         File_Access : Stream_IO.STREAM_ACCESS;
         Name : Unbounded_String := To_Unbounded_String("Undefined");
      end record;
   type File_Type_Access is access all File_Type;


private

end IO;